package com.my.library.service.impl;

import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.my.library.dao.impl.UserDAO;
import com.my.library.entity.Role;
import com.my.library.entity.User;

@Service("userServiceImpl")
public class UserServiceImpl {
	
	Logger log = Logger.getLogger(this.getClass());
	
	@Autowired
	private UserDAO userDAO;

	public User verify(String name, String pwd, StringBuilder msg) {
		User u = userDAO.getUserByName(name);
		if(u == null) {
			msg.append("该用户不存在!");
		} else {
			if(u.getPassword().equals(pwd)) {
				msg.append("用户已登录");
			} else {
				msg.append("密码错误!");
			}
		}
		return u;
	}

	public List<Map<String, Object>> getAppOfUser(int id) {
		return userDAO.getAppOfUser(id);
	}

	public String getData(Set<Role> rs, int appId) {
		return userDAO.getData(rs, appId);
	}

}
